<?php
	echo $this->partial('partial/grandprix.phtml',array('grandprix' => $this->grandprix, 'id' => $this->id));
	$this->title = 'Résultat d\'un Grand-Prix';
	$this->headTitle($this->title);
	if(!is_null($this->gp))
	{
		echo "<p><b>".$this->gp->getGpNom()." (".date('d/m/Y',strtotime($this->gp->getGpDate())).")</b></p>";
		echo "<table class='tabresultat'><tr><th>Place</th><th>Pilote</th><th>Temps</th><th>Nb de points</th></tr>";
		if(count($this->gp->getCourse())!=0)
		{
			$i=1;
			foreach($this->gp->getCourse() as $course)
			{
				$points=0;
				if(count($this->points)>=$i)
				{
					$points=$this->points[$i-1]->getPtNbPointsPlace();
				}
				echo "<tr><td>$i</td><td>".$course->getPilote()->getPilNom()."</td><td>".$course->getTempsCourse()."</td><td>".$points."</td></tr>";
				$i++;
			}
		}
		else
		{
			echo "<tr><td colspan='4'>Pas de résultat pour cette course</td></tr>";
		}
		echo "</table>";
		echo "<div style='float:left;width:340px;padding-left:5px;border-left:1px solid black;'>".$this->gp->getGpCommentaire()."</div>";
	}
	else
	{
		//throw new Zend_Controller_Action_Exception('Page not found.',404);
		echo $this->partial('partial/errorbox.phtml',array('message' => "Le Grand-Prix est introuvable."));
	}
?>